<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客详情</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.2.4/dist/semantic.min.css">
    <link rel="stylesheet" href="../static/css/typo.css" th:href="@{/css/typo.css}">
    <link rel="stylesheet" href="../static/lib/prism/prism.css" th:href="@{/lib/prism/prism.css}">
    <link rel="stylesheet" href="../static/lib/tocbot/tocbot.css" th:href="@{/lib/tocbot/tocbot.css}">
    <link rel="stylesheet" href="../static/css/me.css" th:href="@{/css/me.css}" >
</head>

<body>
    <!--导航-->
    <nav class="ui inverted attached segment m-padded-tb-mini m-shadow-small">
        <div class="ui container ">
            <div class="ui  inverted secondary stackable menu">
                <h2 class="ui teal header item">Blog</h2>
                <a href="#" th:href="@{/}" class="active m-item item m-mobile-hide"><i class=" home icon"></i> 首页</a>
                <a href="#" th:href="@{/types/-1}"  class=" m-item item m-mobile-hide"><i class=" idea icon"></i> 分类</a>
                <a href="#" th:href="@{/tags/-1}" class=" m-item item m-mobile-hide"><i class=" tags icon"></i> 标签</a>
                <a href="#" th:href="@{/archives}" class=" m-item item m-mobile-hide"><i class=" clone icon"></i> 归档</a>
                <a href="#" th:href="@{/about}" class=" m-item item m-mobile-hide"><i class=" info icon"></i> 关于我</a>
                <div class="right m-item item m-mobile-hide">
                    <div class="ui icon inverted transparent input">
                        <form name="search" action="#" th:action="@{/search}" method="post" target="_blank">
                            <div class="ui icon inverted transparent input">
                                <input type="text" name="query" placeholder="Search..." th:value="${query}">
                                <i onclick="document.forms['search'].submit()" class="search link icon"></i>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <a href="#" class="ui menu toggle black icon button m-right-top m-mobile-show">
            <i class="sidebar icon"></i>
        </a>
    </nav>
    <!--中间内容-->
    <div class="m-padded-tb-big m-container-small animated wobble ">
        <div class="ui container">
            <div class="ui top attached segment">
                <div class="ui  horizontal link list">
                    <div class="item">
                        <img src="https://picsum.photos/id/1/60/60?image=1005" th:src="@{${blog.user.avatar}}" alt="" class="ui avatar image">
                        <div class="content"><a href="#" class="header" th:text="${blog.user.nickName}">王勇强</a></div>
                    </div>
                    <div class="item">
                        <i class="calendar icon"></i><span th:text="${#dates.format(blog.updateTime,'yyyy-MM-dd')}">2020-08-01</span>
                    </div>
                    <div class="item">
                        <i class="eye icon"></i><span th:text="${blog.views}">66</span>
                    </div>
                </div>
            </div>
            <div class="ui attached segment">
                <!-- 图片区 -->
                <img src="https://picsum.photos/id/1/800/450?image=1005" th:src="@{${blog.firstPicture}}" alt="" class="ui fluid rounded image">
            </div>
            <div class="ui attached padded segment">
                <!-- 主要内容 -->
                <div class="ui right aligned basic segment">
                    <div class="ui orange basic label" th:text="${blog.flag}">原创</div>
                </div>
                <h3 class="ui center aligned header" th:text="${blog.title}"> 你，活着的意义是什么？你，又为了什么而活着？</h3>
                <div id="content" class=" js-toc-content typo typo-selection m-padded-tb-large m-padded-lr-responsive" th:utext="${blog.content}">
                    <!-- 代码高亮显示 -->
                    <pre><code class="language-css">
                p { color: red }
                h1,h2,h3,h4,h5,h6 {
                line-height:1;font-family:Arial,sans-serif;margin:1.4em 0 0.8em;
            }
            h1{font-size:1.8em;}
            h2{font-size:1.6em;}
            h3{font-size:1.4em;}
            h4{font-size:1.2em;}
            h5,h6{font-size:1em;}
            
            /* 现代排版：保证块/段落之间的空白隔行 */
            .typo p, .typo pre, .typo ul, .typo ol, .typo dl, .typo form, .typo hr {
                margin:1em 0 0.6em;
            }
          </code></pre>
                </div>
                <!-- 标签 -->
                <div class="m-padded-lr-responsive ">
                    <div class="ui basic teal left pointing label" th:each="tag : ${blog.tags}" th:text="${tag.name}">
                        思考与感悟
                    </div>
                </div>
                <!-- 赞赏 -->
                <div th:if="${blog.appreciation}">
                    <div class="ui center aligned basic  segment"> <button id="payButton" class="ui  orange basic circular button">赞赏</button>
                    </div>
                    <div class="ui payQ flowing popup  transition hidden">
                        <div class="ui orange basic label">
                            <div class="ui  images" style="font-size: inherit  !important;">
                                <div class="image">
                                    <img src="../static/images/wechat.jpg" th:src="@{/images/wechat.jpg}" alt="" class="ui rounded bordered image" style="width: 120px;">
                                    <div>支付宝</div>
                                </div>
                                <div class="image">
                                    <img src="../static/images/wechat.jpg" th:src="@{/images/wechat.jpg}" alt="" class="ui rounded bordered image" style="width: 120px;">
                                    <div>微信</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="ui attached positive message" th:if="${blog.shareStatement}">
                <!-- 博客信息 -->
                <div class="ui middle aligned grid">
                    <div class="eleven wide column">
                        <ul class="list">
                            <li>作者： <span th:text="${blog.user.nickName}">王勇强</span> <a href="#" th:href="@{/about}" target="_blank">（联系作者）</a></li>
                            <li>发表时间：<span th:text="${#dates.format(blog.updateTime,'yyyy-MM-dd HH:mm')}">2020-08-01</span></li>
                            <li>版权声明 非商业-不能转载-如有需要-联系作者</li>
                            <li>公众号转载：请在文末添加作者公众号二维码</li>
                        </ul>
                    </div>
                    <div class="five wide column">
                        <img src="../static/images/wechat.jpg" th:src="@{/images/wechat.jpg}" alt="" class="ui right floated rounded bordered image" style="width: 110px;">
                    </div>
                </div>
            </div>
            <div  class="ui bottom attached segment" th:if="${blog.commentTabled}">
                <!-- 留言区列表 -->
                <div id="comment-container" class="ui teal segment" >
                    <div  th:fragment="commentList">
                        <div class="ui comments" style="max-width: 100%;">
                            <h3 class="ui dividing header">评论</h3>
                            <div class="comment" th:each="comment : ${comments}">
                                <a class="avatar">
                                    <img src="https://picsum.photos/id/1/800/450?image=1006" th:src="@{${comment.avatar}}">
                                </a>
                                <div class="content m-text-thin " >
                                    <a class="author" >
                                        <span th:text="${comment.nickName}">Matt</span >
                                        <div class="ui mini basic teal left pointing label m-padded-mini" th:if="${comment.adminComment}">博主</div>
                                    </a>
                                    <div class="metadata">
                                        <span class="date" th:text="${#dates.format(comment.createTime,'yyyy-MM-dd HH:mm')}">Today at 5:42PM</span>
                                    </div>
                                    <div class="text" th:text="${comment.content}">
                                        How artistic!
                                    </div>
                                    <div class="actions">
                                        <a class="reply" data-commentid="1" data-commentnickname="Matt" th:attr="data-commentid=${comment.id},data-commentnickname=${comment.nickName}" onclick="reply(this)">回复</a>
                                    </div>
                                </div>
                                <div class="comments" th:if="${#arrays.length(comment.replayComments)}>0">
                                    <div class="comment" th:each="reply : ${comment.replayComments}">
                                        <a class="avatar">
                                            <img src="https://picsum.photos/id/1/800/450?image=1006" th:src="@{${reply.avatar}}">
                                        </a>
                                        <div class="content m-text-thin" >
                                            <a class="author"><span  th:text="${reply.nickName}">小红</span>
                                                <div class="ui mini basic teal left pointing label m-padded-mini" th:if="${reply.adminComment}">博主</div>
                                                &nbsp;<span th:text="|@ ${reply.parentComment.nickName}|" style="color: lightseagreen">@ 小白</span></a>
                                            <div class="metadata">
                                                <span class="date" th:text="${#dates.format(reply.createTime,'yyyy-MM-dd HH:mm')}">Today at 5:42PM</span>
                                            </div>
                                            <div class="text" th:text="${reply.content}" >
                                               How artistic!
                                            </div>
                                            <div class="actions">
                                                <a class="reply" data-commentid="1" data-commentnickname="Matt" th:attr="data-commentid=${reply.id},data-commentnickname=${reply.nickName}" onclick="reply(this)">回复</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--/*-->
                            <div class="comment">
                                <a class="avatar">
                                    <img src="https://picsum.photos/id/1/800/450?image=1007">
                                </a>
                                <div class="content">
                                    <a class="author">Elliot Fu</a>
                                    <div class="metadata">
                                        <span class="date">Yesterday at 12:30AM</span>
                                    </div>
                                    <div class="text">
                                        <p>This has been very useful for my research. Thanks as well!</p>
                                    </div>
                                    <div class="actions">
                                        <a class="reply">回复</a>
                                    </div>
                                </div>
                                <div class="comments">
                                    <div class="comment">
                                        <a class="avatar">
                                            <img src="https://picsum.photos/id/1/800/450?image=1008">
                                        </a>
                                        <div class="content">
                                            <a class="author">Jenny Hess</a>
                                            <div class="metadata">
                                                <span class="date">Just now</span>
                                            </div>
                                            <div class="text">
                                                Elliot you are always so right :)
                                            </div>
                                            <div class="actions">
                                                <a class="reply">回复</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="comment">
                                <a class="avatar">
                                    <img src="https://picsum.photos/id/1/800/450?image=1004">
                                </a>
                                <div class="content">
                                    <a class="author">Joe Henderson</a>
                                    <div class="metadata">
                                        <span class="date">5 days ago</span>
                                    </div>
                                    <div class="text">
                                        Dude, this is awesome. Thanks so much
                                    </div>
                                    <div class="actions">
                                        <a class="reply">回复</a>
                                    </div>
                                </div>
                            </div>
                            <!--*/-->
                        </div>
                        </div>
                    </div>

                    <div id="comment-form" class="ui form">
                        <input type="hidden" name="blog.id" th:value="${blog.id}">
                        <input type="hidden" name="parentComment.id" value="-1">
                        <div class="field">
                            <textarea name="content" placeholder="请输入评论信息..."></textarea>
                        </div>
                        <div class="fields">
                            <div class="field m-mobile-wide m-margin-bottom-mini">
                                <div class="ui left aligned icon input">
                                    <i class="user icon"></i>
                                    <input type="text" name="nickName" placeholder="姓名" th:value="${session.user}!=null ? ${session.user.nickName}">
                                </div>
                            </div>
                            <div class="field m-mobile-wide m-margin-bottom-mini">
                                <div class="ui left aligned icon input">
                                    <i class="mail icon"></i>
                                    <input type="text" name="email" placeholder="邮箱" th:value="${session.user}!=null ? ${session.user.email}">
                                </div>
                            </div>
                            <div class="field m-mobile-wide m-margin-bottom-mini">
                                <button id="commentpost-btn" type="button" class="ui teal button m-mobile-wide"><i class="edit icon"></i>发布</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="m-fixed m-right-bottom m-padded">
            <div class="ui  vertical icon buttons ">
                <button type="button" class="ui toc teal button">目录</button>
                <a href="#comment-container" class="ui teal button">留言</a>
                <button class="ui wechat icon button"><i class="weixin icon"></i></button>
                <a href="#" id="toTop-button" class="ui icon  button"><i class="chevron up icon"></i></a>
            </div>
        </div>
        <div class="ui toc-container flowing popup  transition hidden" style="width: 250px !important;">
            <ol class="js-toc">
            </ol>
        </div>
        <div id="qrcode" class="ui wechatQR flowing popup  transition hidden " style="width: 130px !important;">
            <!--  <img src="./images/wechat.jpg" alt="" class="ui rounded image" style="width: 120px !important;"> -->
        </div>
        </div>
        <!--底部footer-->
        <footer class="ui inverted vertical segment m-padded-tb-massive">
            <div class="ui center aligned container">
                <div class="ui inverted divided stackable grid">
                    <div class="three wide column">
                        <div class="ui inverted link list">
                            <div class="item">
                                <img src="./images/wechat.jpg" th:src="@{/images/wechat.jpg}" class="ui rounded image" alt="" style="width: 110px;">
                            </div>
                        </div>
                    </div>
                    <div class="three wide column">
                        <h4 class="ui inverted header m-text-thin m-text-spaced">最新博客</h4>
                        <div id="newblog-container">
                            <div class="ui inverted link list" th:fragment="newblogList">
                                <a href="#" th:href="@{/blog/{id}(id=${blog.id})}" target="_blank" class="item" th:each="blog : ${newblogs}" th:text="${blog.title}">用户故事 （User Story）</a>
                            </div>
                        </div>
                    </div>
                    <div class="three wide column">
                        <h4 class="ui inverted header m-text-thin m-text-spaced">联系我</h4>
                        <div class="ui inverted link list">
                            <a href="#" class="item">Email: 1586881615@qq.com </a>
                            <a href="#" class="item">QQ: 1586881615</a>
                            <a href="#" class="item">telephone: 15379258647</a>
                        </div>
                    </div>
                    <div class="seven wide column">
                        <h4 class="ui inverted header m-text-thin m-text-spaced ">Blog</h4>
                        <p class="m-text-thin m-text-spaced m-opacity-mini">这是我的个人博客，希望和大家共同交流，一起进步，欢迎来到这里的各位，希望可以对你们有所帮助。</p>
                    </div>
                </div>
                <div class="ui inverted section divider"></div>
                <p class="m-text-thin m-text-spaced m-opacity-tiny">This is my first system </p>
            </div>

        </footer>
        <script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/jquery.scrollto@2.1.2/jquery.scrollTo.min.js"></script>
        <script src="../static/lib/prism/prism.js " th:src="@{/lib/prism/prism.js}"></script>
        <script src="../static/lib/tocbot/tocbot.js" th:src="@{/lib/tocbot/tocbot.js}"></script>
        <script src="../static/lib/tocbot/tocbot.min.js" th:src="@{/lib/tocbot/tocbot.min.js}"></script>
        <script src="../static/lib/qrcode/qrcode.min.js" th:src="@{/lib/qrcode/qrcode.min.js}"></script>
        <script th:inline="javascript">
            $('.menu.toggle').click(function() {
                $('.m-item').toggleClass('m-mobile-hide');
            });
            $('#payButton').popup({
                popup: $('.payQ.popup'),
                on: 'click',
                position: 'bottom center'
            });
            $('.toc.button').popup({
                popup: $('.toc-container.popup'),
                on: 'click',
                position: 'left center'
            });
            tocbot.init({
                tocSelector: '.js-toc',
                cootentSelector: '.js-toc-content',
                headingSelector: 'h1, h2, h3',
            });
            $('.wechat').popup({
                popup: $('.wechatQR'),
                position: 'left center'
            });
            /*var waypoint = new Waypoint({
                element: document.getElementById('waypoint'),
                handler: function (direction) {
                    if (direction == 'down'){
                        $('#toolbar').show(100);
                    }else {
                        $('#toolbar').hide(50);
                    }
                    console.log('Scrolled to waypoint! '+direction);
                }
            });*/
            var serurl="127.0.0.1:8080";
            var url = /*[[@{/blog/{id}(id=${blog.id})}]]*/"";
            var qrcode = new QRCode("qrcode", {
                text: serurl+url,
                width: 100,
                height: 100,
                colorDark: "#000000",
                colorLight: "#ffffff",
                correctLevel: QRCode.CorrectLevel.H
            });
            $('#toTop-button').click(function () {
                $(window).scrollTo(0,500);
            });

            $('.ui.form').form({
                fields: {
                    content: {
                        identifier: 'content',
                        rules: [
                            {
                                type   : 'empty',
                                prompt : '标题 ：请输入评论内容'
                            }]
                    },
                    nickName: {
                        identifier: 'nickName',
                        rules: [
                            {
                                type   : 'empty',
                                prompt : '标题 ：请输入你的昵称'
                            }]
                    },
                    email: {
                        identifier: 'email',
                        rules: [
                            {
                                type   : 'empty',
                                prompt : '标题 ：请输入正确的邮箱地址'
                            }]
                    }
                }
            });
            $(function () {
                $("#comment-container").load(/*[[@{/comments/{id}(id=${blog.id})}]]*/"comments/6");
            })
            $('#commentpost-btn').click(function () {
             var boo =  $('.ui.form').form('validate form');
             if (boo){
                 console.log("校验成功");
                 postData();
             }else {
                 console.log("校验失败");
             }
            });
            function postData() {
                $("#comment-container").load(/*[[@{/comments}]]*/"",{
                    "parentComment.id" : $("[name='parentComment.id']").val(),
                    "blog.id" : $("[name='blog.id']").val(),
                    "nickName" : $("[name='nickName']").val(),
                    "email" : $("[name='email']").val(),
                    "content" : $("[name='content']").val()
                },function (responseTxt, statusTxt, xhr) {
                    // $(window).scrollTo($('#comment-container'),500);
                    clearContent();
                });
            };
            function clearContent() {
                $("[name='content']").val('');
                $("[name='parentComment.id']").val(-1);
                $("[name='content']").attr("placeholder","请输入评论信息...");
            };
            function reply(obj) {
                var commentId = $(obj).data('commentid');
                var commentNickname = $(obj).data('commentnickname');
                $("[name='content']").attr("placeholder","@"+commentNickname).focus();
                $("[name='parentComment.id']").val(commentId);
                $(window).scrollTo($('#comment-form'),500);
            };
            $('#newblog-container').load(/*[[@{/footer/newblog}]]*/"/footer/newblog");
        </script>
</body>

</html>